<?php

namespace App\Http\Resources\Api;

use App\Models\Enum\UserEnum;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class UserResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     * @param  Request  $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            'id'            => $this->id,
            'nickname'      => $this->nickname,
            'avatar'        => $this->avatar,
            'gender'        => $this->gender,
            'gender_todo'   => UserEnum::getGenderName($this->gender),
            'wx_openid'     => $this->wx_openid,
            'mobile'        => $this->mobile,
            'status'        => $this->status,
            'created_at'    => $this->created_at,
            'updated_at'    => $this->updated_at,
        ];
    }
}
